package pl.vanta.utils.ejb.ejbqlb.parts;

import java.util.ArrayList;
import java.util.List;

public class OrderBy<T> extends AbstractEndPart<T>
{
	private List<String>	orders;

	public OrderBy(AbstractPart<T> qp, String name, String order)
	{
		super(qp);

		this.orders = new ArrayList<String>();

		addOrderBy(name, order);
	}

	@Override
	public String getPart()
	{
		return this.parent.getPart() + " ORDER BY ";
	}

	private OrderBy<T> addOrderBy(String name, String order)
	{
		String s = name + " " + order;
		this.orders.add(s);

		return this;
	}

	public OrderBy<T> ORDER_BY_DESC(String name)
	{
		return addOrderBy(name, "DESC");
	}

	public OrderBy<T> ORDER_BY_ASC(String name)
	{
		return addOrderBy(name, "ASC");
	}
}